//
//  BookTypeSearchView.m
//  LiteraryTune
//
//  Created by 神州四达 on 2018/1/16.
//  Copyright © 2018年 cxd. All rights reserved.
//

#import "BookTypeSearchView.h"

@interface BookTypeSearchView ()

@end

@implementation BookTypeSearchView
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self createView];
    }
    return self;
}

- (void)createView {
    [self addSubview:self.nameTF];
    [self addSubview:self.searchBtn];
}

#pragma mark - 懒加载
- (UITextField *)nameTF {
    if (!_nameTF) {
        _nameTF = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, kScreenWidth - 100, 40)];
        _nameTF.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"书名、作者名" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15],NSForegroundColorAttributeName:MainLightGrayColor}];
        _nameTF.layer.borderColor = LineDefaultGrayColor.CGColor;
        _nameTF.layer.borderWidth = 1.f;
        UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 8, 0)];
        _nameTF.leftView = leftView;
        _nameTF.leftViewMode = UITextFieldViewModeAlways;
    }
    return _nameTF;
}

- (UIButton *)searchBtn {
    if (!_searchBtn) {
        _searchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _searchBtn.frame = CGRectMake(kScreenWidth - 80, 10, 70, 40);
        _searchBtn.backgroundColor = MainGreenColor;
        _searchBtn.titleLabel.font = [UIFont boldSystemFontOfSize:15];
        [_searchBtn setTitle:@"搜索" forState:UIControlStateNormal];
        [_searchBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    }
    return _searchBtn;
}

@end
